package com.topfinance.payment.service.impl;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.BeanUtils;

import com.topfinance.cnaps2.ebo.SysOrgEbo;
import com.topfinance.frame.dao.HibernateEntityDao;
import com.topfinance.frame.exception.AppException;
import com.topfinance.payment.ebo.TCfgNodeEbo;
import com.topfinance.payment.service.ITCfgNodeMgr;

/**
 * 该类自动实现了dao的一般方法，如add, remove, update
 * 在service中出现的大部分情况下是在向后台提交数据前的处理(如校验)及获取后台数据后的处理等
 * 
 * @author
 * 
 */

public class TCfgNodeMgrImpl extends HibernateEntityDao<TCfgNodeEbo> implements ITCfgNodeMgr {

	private static final Log log = LogFactory.getLog(TCfgNodeMgrImpl.class);

	// 获得传输协议
	public void addNode(TCfgNodeEbo o) throws AppException {
		save(o);
	}

	public void editNode(TCfgNodeEbo o) throws AppException {
		// 删除原始传输协议和部门映射
		// ConfNodeEbo user = get(o.getUserId());
		// deleteDepartUserMap(o.getUserId());
		// flush();
		// clear();
		// 保存传输协议
		saveOrUpdate(o);
		// save(sysDepartmentUserMapEbo);
	}

	// 获得传输协议
	public TCfgNodeEbo getNode(Integer oid) throws AppException {
		return (TCfgNodeEbo) get(oid);
	}

	public void deleteNode(TCfgNodeEbo o) throws AppException {
		removeById(o.getClass(), o.getOid());
	}

	public void deleteNode(Integer oid) throws AppException {
		removeById(TCfgNodeEbo.class, oid);
	}

	// 获得传输协议列表
	public List<TCfgNodeEbo> getAllNode() throws AppException {
		String hql = " from TCfgNodeEbo t ";
		String where = "";
		List<Object> paramList = new ArrayList<Object>();
		if (isNotBlank(where)) {
			where = " where " + where;
		}
		hql = hql + where;
		return find(hql, paramList.toArray());
	}

}
